package com.xge.common_libary.http

suspend fun <T> safeApiCall(call: suspend () -> BaseResponse<T>): ApiResult<T> {
    return try {
        val response = call()
        if (response.code == 200 && response.result != null) {
            ApiResult.Success(response.result)
        }else if(response.msg.contains("数据返回为空")){
            ApiResult.Error(response.code, "对不起，暂无该项相关信息")
        }
        else {
            ApiResult.Error(response.code, response.msg)
        }
    } catch (e: Exception) {
        ApiResult.Exception("请求失败。。。")
    }
}
